package com.xd.springboot.controller;

import com.xd.springboot.config.MicroServiceUrl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/config")
public class ConfigController {


    private  static  final Logger logger= LoggerFactory.getLogger(ConfigController.class);

    //使用Value注解直接从配置文件中读取
    @Value("${url.orderUrl}")
    private  String orderUrl;

    //使用Resource读取 @ConfigurationProperties(prefix = "url") 中的值
    @Resource
    private MicroServiceUrl microServiceUrl;

    @RequestMapping("/test")
    public String getConfig(){
        logger.info("==========订单地址：{}",orderUrl);
        logger.info("==========订单地址：{}",microServiceUrl.getUserUrl());
        return "success";
    };
}
